package io.adrainty.bolee.trade.feign;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.trade.hystrix.CommonPayFeignHystrix;
import io.adrainty.bolee.trade.models.entity.RefundRecordEntity;
import io.adrainty.bolee.trade.models.entity.TradeEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author AdRainty
 * @version V1.0.0
 * @since 2025/8/31 下午11:13
 */

@FeignClient(value = "trade-web", path = "/trade-common-feign", fallback = CommonPayFeignHystrix.class)
public interface ICommonPayFeign {

    /**
     * 查询交易
     *
     * @param tradeVO 交易信息
     * @return 交易信息
     */
    @PostMapping("/query")
    ResultDTO<TradeEntity> queryTrade(@RequestBody TradeEntity tradeVO);

    /**
     * 退款交易
     *
     * @param tradeVO 退款信息
     * @return 退款信息
     */
    @PostMapping("/refund")
    ResultDTO<TradeEntity> refundTrade(@RequestBody TradeEntity tradeVO);

    /**
     * 查询退款交易
     *
     * @param refundRecordEntity 退款信息
     * @return 退款信息
     */
    @PostMapping("/query-refund")
    ResultDTO<RefundRecordEntity> queryRefundTrade(@RequestBody RefundRecordEntity refundRecordEntity);

    /**
     * 关闭交易
     * <p>1、商户订单支付失败需要生成新单号重新发起支付，要对原订单号调用关单，避免重复支付；</p>
     * <p>2、系统下单后，用户支付超时，系统退出不再受理，避免用户继续，请调用关单接口。</p>
     *
     * @param tradeVO 关闭信息
     * @return 关闭信息
     */
    @PostMapping("/close")
    ResultDTO<TradeEntity> closeTrade(@RequestBody TradeEntity tradeVO);

    /**
     * 下载对账单
     *
     * @param tradeVO 下载信息
     * @return 下载信息
     */
    @PostMapping("/down-load-bill")
    ResultDTO<String> downLoadBill(@RequestBody TradeEntity tradeVO);

    /**
     * 同步支付任务
     *
     * @return 同步结果
     */
    @PostMapping("/sync-payment-job")
    ResultDTO<Boolean> syncPaymentJob();

}
